import axios, { type InternalAxiosRequestConfig } from 'axios';

const api = axios.create({
  baseURL: 'http://localhost:8080/api', // Your backend API base URL
});

// Add a request interceptor to include the token in headers
api.interceptors.request.use(
  (config: InternalAxiosRequestConfig) => {
    const token = localStorage.getItem('jwt_token'); // Or wherever you store your token
    if (token) {
      if(config.headers) {
        config.headers.Authorization = `Bearer ${token}`;
      }
    }
    return config;
  },
  (error: any) => {
    return Promise.reject(error);
  }
);

export { api };

export const IMAGE_BASE_URL = 'http://localhost:8080/'; 